home *** CD-ROM | disk | FTP | other *** search
/ AMIGA-CD 2 / Amiga-CD - Volume 2.iso / ungepackte_daten / 1992 / 09 / 2 / window-machine / wm_source.ampk / WM_Menu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-01  |  27.0 KB  |  1,640 lines

  1. #include <WM.h>
  2. #include <MyStructs.h>
  3. #include <Menu.h>
  4.  
  5. USHORT OpenMWin(struct NewWindow *window,struct IntuiText *tx)
  6. {
  7.     HEIGHTBuff[0]=0;
  8.     WIDTHBuff[0]=0;
  9.     TOPBuff[0]=0;
  10.     LEFTBuff[0]=0;
  11.     DEPTHBuff[0]=0;
  12.     TITLEBuff[0]=0;
  13.     if(!(Mwin=(struct Window *)OpenWindow(window))) return(1);
  14.     Mrp=Mwin->RPort;
  15.     WinBorder(Mwin);
  16.     SetFont(Mrp,StdFont);
  17.     PrintIText(Mrp,tx,0,0);
  18.     MenuOn(0);
  19.     return(0);
  20. }
  21. VOID MWinOn(struct Window *win)
  22. {
  23.     if(win->MenuStrip) ClearMenuStrip(win);
  24.     CloseWindow(win);
  25. }
  26. USHORT DefMenu()
  27. {
  28.     USHORT quit=FALSE;
  29.     if(sc->Width < ItemWindow.Width || sc->Height < ItemWindow.Height || sc==WMsc)
  30.     {
  31.         ScreenToFront(WMsc);
  32.         WMsc->Font=sc->Font;
  33.         activS=WMsc;
  34.         x=165;
  35.     }
  36.     else
  37.     {
  38.         activS=sc;
  39.         if(sc->Width == 320 || (sc->Width > 320 &&
  40.             (sc->ViewPort.Modes & HIRES)==0)) x=5;
  41.         else if(sc->Width == 640 && (sc->ViewPort.Modes & HIRES)) x=165;
  42.         else x=0;
  43.     }
  44.     MenuWindow.Screen=activS;
  45.     ItemWindow.Screen=activS;
  46.     MenuWindow.LeftEdge=x;
  47.     ItemWindow.LeftEdge=x;
  48.     amenu=awin->MenuStrip;
  49.     firstM=amenu;
  50.     lastM=amenu;
  51.     Manz=0;
  52.     Mnr=0;
  53.     while(amenu)
  54.     {
  55.         lastM=amenu;
  56.         Manz++;
  57.         amenu=amenu->Next;
  58.         if(Manz > 9) Mnr++;
  59.     }
  60.     amenu=lastM;
  61.     if(amenu==NULL) NoMenu();
  62.     else HolItem();
  63.     OldMenu=amenu;
  64.     OldItem=aitem;
  65.     if(OpenMWin(&MenuWindow,&MenuText[4])) return(1);
  66.     MType=0;
  67.     SY=0;
  68.     SetMDefines();
  69.     ActivateGadget(&MEingabe,Mwin,NULL);
  70.  
  71.     do
  72.     {
  73.         Wait(1L << Mwin->UserPort->mp_SigBit);
  74.         while(Mmsg=(struct IntuiMessage*)GetMsg(Mwin->UserPort))
  75.         {
  76.             HolMsg(Mmsg);
  77.         switch(class)
  78.         {
  79.             case MOUSEMOVE: SY=1;
  80.                     break;
  81.             case GADGETUP:
  82.             switch(Id)
  83.             {
  84.                 case 0: quit=TRUE;
  85.                     break;
  86.                 case 1:
  87.                 case 2:
  88.                 case 3:
  89.                 case 4:
  90.                 case 5:
  91.                 case 6:
  92.                 case 7:
  93.                 case 8:
  94.                 case 9:
  95.                 case 10:
  96.                 if(MType==0)
  97.                 {
  98.                     if(firstM) RetteMenu();
  99.                     AktM();
  100.                     if(helpM==NULL) NewMenu();
  101.                     SetMDefines();
  102.                     ActivateGadget(&MEingabe,Mwin,NULL);
  103.                     break;
  104.                 }
  105.                 if(MType==1)
  106.                 {
  107.                     if(aitem) RetteItem(1);
  108.                     AktI();
  109.                     aitem=helpJ;
  110.                     if(helpJ==NULL) NewItem();
  111.                     SetIDefines();
  112.                     ActivateGadget(&IEingabe,Mwin,NULL);
  113.                     break;
  114.                 }
  115.                 if(asub) RetteItem(1);
  116.                 AktI();
  117.                 asub=helpJ;
  118.                 if(helpJ==NULL) NewSub();
  119.                 SetIDefines();
  120.                 ActivateGadget(&IEingabe,Mwin,NULL);
  121.                 break;
  122.                 /* Zum Menu */
  123.                 case 80: if(MType==0) break;
  124.                     MWinOn(Mwin);
  125.                     OpenMWin(&MenuWindow,&MenuText[4]);
  126.                     MType=0;
  127.                     SetMDefines();
  128.                     ShowMenu();
  129.                     ActivateGadget(&MEingabe,Mwin,NULL);
  130.                     break;
  131.                 /* Zum Item */
  132.                 case 81: if(amenu==NULL || MType==1) break;
  133.                     MWinOn(Mwin);
  134.                     OpenMWin(&ItemWindow,&MenuText[13]);
  135.                     MType=1;
  136.                     SetIDefines();
  137.                     ShowItem();
  138.                     ActivateGadget(&IEingabe,Mwin,NULL);
  139.                     break;
  140.                 /* Zum Sub */
  141.                 case 82: if(aitem==NULL || MType==2) break;
  142.                     MWinOn(Mwin);
  143.                     OpenMWin(&ItemWindow,&MenuText[14]);
  144.                     MType=2;
  145.                     SetIDefines();
  146.                     ShowItem();
  147.                     ActivateGadget(&IEingabe,Mwin,NULL);
  148.                     break;
  149.                 /* Menu-Auto */
  150.                 case 76: Mauto ^= 1;
  151.                     break;
  152.                 /* Item-Image */
  153.                 case 29: DeIm(2);
  154.                     break;
  155.                 /* Select-Image */
  156.                 case 28: DeIm(3);
  157.                     break;
  158.                 /* OK - Menu */
  159.                 case 11: if(MType==0)
  160.                 {
  161.                     if(amenu) RetteMenu();
  162.                     break;
  163.                 }
  164.                 if(MType==1)
  165.                 {
  166.                     if(aitem) RetteItem(1);
  167.                     break;
  168.                 }
  169.                 if(asub) RetteItem(1);
  170.                 break;
  171.                 /* LĂ–SCHEN - Menu */
  172.                 case 13: if(MType==0)
  173.                 {
  174.                     if(amenu)
  175.                     {
  176.                         if(Error(19,1,0)==0) break;
  177.                         LoeschM();
  178.                         
  179.                         if(helpM==NULL)
  180.                         {
  181.                             NoMenu();
  182.                             WMItem5.Flags=ItemOff;
  183.                             WMItem5b.Flags=ItemOff;
  184.                         }
  185.                         MAus();
  186.                         DelMenu();
  187.                         amenu=helpM;
  188.                         MenuOn(0);
  189.                         SetMDefines();
  190.                     }
  191.                     break;
  192.                 }
  193.                 if(MType==1)
  194.                 {
  195.                     if(aitem)
  196.                     {
  197.                         if(Error(21,1,0)==0) break;
  198.                         LoeschI(1);
  199.                     }
  200.                     break;
  201.                 }
  202.                 if(asub)
  203.                 {
  204.                     if(Error(22,1,0)==0) break;
  205.                     LoeschI(1);
  206.                 }
  207.                 break;
  208.                 case 46: strcpy(Icom,DEPTHBuff);
  209.                     break;
  210.                 case 45:
  211.                 case 14: Mleft=LEFTInfo.LongInt;
  212.                     break;
  213.                 case 15:
  214.                 case 44: Mtop=TOPInfo.LongInt;
  215.                     break;
  216.                 case 43:
  217.                 case 19: Mwidth=WIDTHInfo.LongInt;
  218.                     break;
  219.                 case 42:
  220.                 case 20: Mheight=HEIGHTInfo.LongInt;
  221.                     break;
  222.                 /* MENUENABLED */
  223.                 case 21: Mflag ^= 1;
  224.                     break;
  225.                 /* ITEMFLAGS */
  226.                 case 35:
  227.                 case 36:
  228.                 case 37:
  229.                 case 38: Mflag ^= MFLAGS[Id-35];
  230.                     break;
  231.                 /* ItemText */
  232.                 case 33: DeTx(MType+1);
  233.                     break;
  234.                 break;
  235.                 /* SelectText */
  236.                 case 34: DeTx(MType+3);
  237.                     break;
  238.             } /* switch Id */
  239.             break;
  240.             case GADGETDOWN:
  241.             switch(Id)
  242.             {
  243.             /* PLATZ-MENU */
  244.                 case 12:
  245.                 if(amenu)
  246.                 {
  247.                     if(amenu == firstM && amenu == lastM)
  248.                         break;
  249.                     PlaceMenu();
  250.                 }
  251.                 break;
  252.             /* PLATZ-ITEM */
  253.                 case 32:
  254.                 if(MType==1 && aitem != NULL)
  255.                 {
  256.                     if(aitem == firstI && aitem == lastI)
  257.                         break;
  258.                     PlaceItem();
  259.                     break;
  260.                 }
  261.                 if(asub)
  262.                 {
  263.                     if(asub == Sfirst && asub == Slast)
  264.                         break;
  265.                     PlaceItem();
  266.                 }
  267.                 break;
  268.                 case 39:
  269.                 case 40:
  270.                 case 41:
  271.                 Id-=35;
  272.                 Mflag = (Mflag & 0xFF3F)|MFLAGS[Id];
  273.                 SetPen(Mrp,0,JAM1);
  274.                 RectFill(Mrp,6,128,93,160);
  275.                 SetDrMd(Mrp,COMPLEMENT);
  276.                 RefreshGList(&IFlag[6],Mwin,NULL,3);
  277.                 Id=(Id-4)*12;
  278.                 RectFill(Mrp,6,128+Id,93,136+Id);
  279.                 break;
  280.             /* EXCLUDE-ITEM */
  281.                 case 27: ExcludeI();
  282.                     break;
  283.                 default: TestProp();
  284.                     break;
  285.             } /* switch Id */
  286.  
  287.             }/* switch class */
  288.             if(quit==FALSE) Modify();
  289.         }
  290.     }while(quit==FALSE); /* do */
  291.     MWinOn(Mwin);
  292.     WMsc->Font=&ZS8;
  293.     ScreenToFront(sc);
  294.     return(0);
  295. }
  296. VOID DeTx(UBYTE m)
  297. {
  298.     i=0;
  299.     if((MType==1 && aitem != NULL) || (MType==2 && asub != NULL))
  300.     {
  301.         MAus();
  302.         if(DefText(m)) Error(0,1,1);
  303.         ScreenToFront(activS);
  304.         MenuOn(0);
  305.     }
  306. }
  307. VOID DeIm(UBYTE m)
  308. {
  309.     i=0;
  310.     if(MType==1 && aitem != NULL) i=m;
  311.     else
  312.     {
  313.         if(MType==2 && asub != NULL)
  314.             i=m+2;
  315.     }
  316.     if(i)
  317.     {
  318.         MAus();
  319.         DefImage(i);
  320.         ScreenToFront(activS);
  321.         ActivateWindow(Mwin);
  322.         MenuOn(0);
  323.     }
  324. }
  325. VOID TestProp()
  326. {
  327.     switch(Id)
  328.     {
  329.         /* Prop-Menu */
  330.         case 16: SY=1;
  331.             break;
  332.         /* Up-Menu */
  333.         case 17: SY=2;
  334.             break;
  335.         case 18: SY=3;
  336.             break;
  337.     }
  338. }
  339. VOID Modify()
  340. {
  341.     if(SY==1)
  342.     {
  343.         if(MType==0)
  344.         {
  345.             if(Manz > 9)
  346.             {
  347.                 i=Mnr;
  348.                 Mnr=((MenuPropInfo.VertPot+1)*(Manz-9)/65535);
  349.                 if(i!=Mnr) ShowMenu();
  350.             }
  351.         }
  352.         if(MType==1)
  353.         {
  354.             if(Ianz > 9)
  355.             {
  356.                 i=Inr;
  357.                 Inr=((MenuPropInfo.VertPot+1)*(Ianz-9)/65535);
  358.                 if(i!=Inr) ShowItem();
  359.             }
  360.         }
  361.         if(MType==2)
  362.         {
  363.             if(Sanz > 9)
  364.             {
  365.                 i=Snr;
  366.                 Snr=((MenuPropInfo.VertPot+1)*(Sanz-9)/65535);
  367.                 if(i!=Snr) ShowItem();
  368.             }
  369.         }
  370.         SY=0;
  371.     }
  372.     if(SY > 1)
  373.     {
  374.         while(class != GADGETUP)
  375.         {
  376.             if(SY==2)
  377.             {
  378.                 if(MType==0)
  379.                 {
  380.                     if(Mnr)
  381.                     {
  382.                         Mnr--;
  383.                         SetMWert();
  384.                     }
  385.                 }
  386.                 if(MType==1)
  387.                 {
  388.                     if(Inr)
  389.                     {
  390.                         Inr--;
  391.                         SetIWert();
  392.                     }
  393.                 }
  394.                 if(MType==2)
  395.                 {
  396.                     if(Snr)
  397.                     {
  398.                         Snr--;
  399.                         SetSWert();
  400.                     }
  401.                 }
  402.             }
  403.             else
  404.             {
  405.                 if(MType==0)
  406.                 {
  407.                     if((Mnr+9)<Manz)
  408.                     {
  409.                         Mnr++;
  410.                         SetMWert();
  411.                     }
  412.                 }
  413.                 if(MType==1)
  414.                 {
  415.                     if((Inr+9)<Ianz)
  416.                     {
  417.                         Inr++;
  418.                         SetIWert();
  419.                     }
  420.                 }
  421.                 if(MType==2)
  422.                 {
  423.                     if((Snr+9)<Sanz)
  424.                     {
  425.                         Snr++;
  426.                         SetSWert();
  427.                     }
  428.                 }
  429.             }
  430.             GetMessage(Mwin);
  431.         }
  432.         SY=0;
  433.     }
  434. }
  435. VOID NewExclude()
  436. {
  437.     struct MyItem *item1;
  438.     actS=amenu->FirstItem;
  439.     if(MType==2) actS=aitem->Sub;
  440.     actI=actS;
  441.     while(actS)
  442.     {
  443.         if(actS->Exclude)
  444.         {
  445.             item1=actI;
  446.             write=0;
  447.             read=1;
  448.             while(item1)
  449.             {
  450.                 if(actS->Exclude & item1->Bit)
  451.                     write |= read;
  452.                 read = read << 1;
  453.                 item1=item1->Next;
  454.             }
  455.             actS->Exclude=write;
  456.         }
  457.         actS=actS->Next;
  458.     }
  459.     NewBit();
  460. }
  461. USHORT ExcludeI()
  462. {
  463.     UBYTE POK=1;
  464.     if(MType==1 && aitem == NULL) return(0);
  465.     if(MType==2 && asub == NULL) return(0);
  466.     SetDrMd(Mrp,COMPLEMENT);
  467.     RectFill(Mrp,173,100,232,111);
  468.     SY=0;
  469.     do
  470.     {
  471.         Wait(1L << Mwin->UserPort->mp_SigBit);
  472.         while(Mmsg=(struct IntuiMessage*)GetMsg(Mwin->UserPort))
  473.         {
  474.             HolMsg(Mmsg);
  475.         switch(class)
  476.         {
  477.             case MOUSEMOVE: SY=1;
  478.                     break;
  479.             case GADGETUP:
  480.             if(Id > 0 && Id < 11)
  481.             {
  482.                 actS=aitem;
  483.                 if(MType==2) actS=asub;
  484.                 AktI();
  485.                 if(helpJ != NULL && helpJ != actS)
  486.                 {
  487.                     actS->Exclude ^= helpJ->Bit;
  488.                     ShowItem();
  489.                     MenuOn(1);
  490.                 }
  491.             }
  492.             break;
  493.             case GADGETDOWN:
  494.             if(Id==27) POK=0;
  495.             else TestProp();
  496.         }
  497.         Modify();
  498.     }
  499.     } while(POK==1);
  500.     SetDrMd(Mrp,COMPLEMENT);
  501.     RectFill(Mrp,173,100,232,111);
  502.     return(0);
  503. }
  504. VOID NewWidth()
  505. {
  506.     i=0;
  507.     actI=aitem->Sub;
  508.     if(MType==1) actI=amenu->FirstItem;
  509.     actS=actI;
  510.     while(actI)
  511.     {
  512.         if(actI->IstWidth > i) i=actI->IstWidth;
  513.         actI=actI->Next;
  514.     }
  515.     while(actS)
  516.     {
  517.         if(actS->Auto)
  518.         {
  519.             actS->Width = i;
  520.             actI=actS->Sub;
  521.             while(actI)
  522.             {
  523.                 if(actI->Auto) actI->LeftEdge=i;
  524.                 actI=actI->Next;
  525.             }
  526.         }
  527.         actS=actS->Next;
  528.     }
  529. }
  530. VOID LoeschM()
  531. {
  532.     if(amenu->Parent)
  533.     {
  534.         if(amenu->Next)
  535.         {
  536.             NewLeftM();
  537.             helpM=amenu->Next;
  538.             amenu->Next->Parent=amenu->Parent;
  539.         }
  540.         else
  541.         {
  542.             helpM=amenu->Parent;
  543.             lastM=helpM;
  544.         }
  545.         amenu->Parent->Next=amenu->Next;
  546.     }
  547.     else
  548.     {
  549.         if(amenu->Next)
  550.         {
  551.             NewLeftM();
  552.             firstM=amenu->Next;
  553.             helpM=firstM;
  554.             helpM->Parent=NULL;
  555.             awin->MenuStrip=firstM;
  556.         }
  557.         else helpM=NULL;
  558.     }
  559.     Manz--;
  560.     if(Mnr>0 && (Mnr+9)>Manz) Mnr--;
  561. }
  562. VOID LoeschI(UBYTE m)
  563. {
  564.     actI=asub;
  565.     if(MType==1) actI=aitem;
  566.     if(actI->Parent)
  567.     {
  568.         if(actI->Next)
  569.         {
  570.             NewTop();
  571.             helpJ=actI->Next;
  572.             actI->Next->Parent=actI->Parent;
  573.         }
  574.         else
  575.         {
  576.             helpJ=actI->Parent;
  577.             if(MType==1) lastI=helpJ;
  578.             else Slast=helpJ;
  579.         }
  580.         actI->Parent->Next=actI->Next;
  581.     }
  582.     else
  583.     {
  584.         if(actI->Next)
  585.         {
  586.             NewTop();
  587.             if(MType==1)
  588.             {
  589.                 firstI=actI->Next;
  590.                 amenu->FirstItem=firstI;
  591.             }
  592.             else
  593.             {
  594.                 Sfirst=actI->Next;
  595.                 aitem->Sub=Sfirst;
  596.             }
  597.             helpJ=actI->Next;
  598.             helpJ->Parent=NULL;
  599.         }
  600.         else helpJ=NULL;
  601.     }
  602.     if(helpJ==NULL)
  603.     {
  604.         if(MType==1) NoItem();
  605.         else NoSub();
  606.     }
  607.     else
  608.     {
  609.         NewExclude();
  610.         NewWidth();
  611.     }
  612.     MAus();
  613.     if(MType==1)
  614.     {
  615.         if(m)
  616.         {
  617.             DelItem();
  618.             aitem=helpJ;
  619.             SetIDefines();
  620.         }
  621.         Ianz--;
  622.         if(Inr>0 && (Inr+9)>Ianz) Inr--;
  623.     }
  624.     else
  625.     {
  626.         if(m)
  627.         {
  628.             DelSub();
  629.             asub=helpJ;
  630.             SetIDefines();
  631.         }
  632.         Sanz--;
  633.         if(Snr>0 && (Snr+9)>Sanz) Snr--;
  634.     }
  635.     if(m) MenuOn(0);
  636. }
  637. VOID PlaceMenu()
  638. {
  639.     UBYTE POK=1;
  640.     actM=amenu;
  641.     SetPen(Mrp,1,JAM1|COMPLEMENT);
  642.     RectFill(Mrp,50,186,137,194);
  643.     LoeschM();
  644.     SetMWert();
  645.     do
  646.     {
  647.         Wait(1L << Mwin->UserPort->mp_SigBit);
  648.         while(Mmsg=(struct IntuiMessage*)GetMsg(Mwin->UserPort))
  649.         {
  650.             HolMsg(Mmsg);
  651.     switch(class)
  652.     {
  653.         case GADGETUP:
  654.         if(Id > 0 && Id < 11)
  655.         {
  656.             AktM();
  657.             if(helpM==NULL)
  658.             {
  659.                 lastM->Next=actM;
  660.                 actM->Parent=lastM;
  661.                 actM->Next=NULL;
  662.                 actM->LeftEdge=lastM->LeftEdge+lastM->Width;
  663.                 lastM=actM;
  664.             }
  665.             else
  666.             {
  667.                 actM->Parent=helpM->Parent;
  668.                 if(helpM->Parent)
  669.                     helpM->Parent->Next=actM;
  670.                 else
  671.                 {
  672.                     firstM=actM;
  673.                     awin->MenuStrip=firstM;
  674.                 }
  675.                 actM->Next=helpM;
  676.                 helpM->Parent=actM;
  677.                 actM->LeftEdge=helpM->LeftEdge;
  678.                 while(helpM)
  679.                 {
  680.                     helpM->LeftEdge+=actM->Width;
  681.                     helpM=helpM->Next;
  682.                 }
  683.             }
  684.             POK=0;
  685.             amenu=actM;
  686.         }
  687.         break;
  688.         case MOUSEMOVE: SY=1;
  689.                 break;
  690.         case GADGETDOWN:
  691.             TestProp();
  692.             break;
  693.     }
  694.     Modify();
  695.     }
  696.     }while(POK==1);
  697.     Manz++;
  698.     if((Mnr+9)<Manz) Mnr++;
  699.     MenuOn(1);
  700.     SetDrMd(Mrp,JAM1|COMPLEMENT);
  701.     RectFill(Mrp,50,186,137,194);
  702.     SetMDefines();
  703. }
  704. VOID HolMsg(struct IntuiMessage *msg)
  705. {
  706.     class=msg->Class;
  707.     code=msg->Code;
  708.     gad=(struct Gadget*)msg->IAddress;
  709.     Id=gad->GadgetID;
  710.     ReplyMsg(msg);
  711. }
  712. VOID PlaceItem()
  713. {
  714.     UBYTE POK=1;
  715.     actI=asub;
  716.     if(MType==1) actI=aitem;
  717.     SetPen(Mrp,1,JAM1|COMPLEMENT);
  718.     RectFill(Mrp,122,138,209,146);
  719.     LoeschI(0);
  720.     if(MType==1) SetIWert();
  721.     else SetSWert();
  722.     do
  723.     {
  724.         Wait(1L << Mwin->UserPort->mp_SigBit);
  725.         while(Mmsg=(struct IntuiMessage*)GetMsg(Mwin->UserPort))
  726.         {
  727.             HolMsg(Mmsg);
  728.         switch(class)
  729.         {
  730.             case GADGETUP:
  731.         if(Id > 0 && Id < 11)
  732.         {
  733.             AktI();
  734.             if(helpJ==NULL)
  735.             {
  736.                 if(MType==1)
  737.                 {
  738.                     lastI->Next=actI;
  739.                     actI->Parent=lastI;
  740.                     actI->TopEdge=lastI->TopEdge+lastI->Height;
  741.                     lastI=actI;
  742.                 }
  743.                 else
  744.                 {
  745.                     Slast->Next=actI;
  746.                     actI->Parent=Slast;
  747.                     actI->TopEdge=Slast->TopEdge+Slast->Height;
  748.                     Slast=actI;
  749.                 }
  750.                 actI->Next=NULL;
  751.                 
  752.             }
  753.             else
  754.             {
  755.                 actI->Parent=helpJ->Parent;
  756.                 if(helpJ->Parent)
  757.                     helpJ->Parent->Next=actI;
  758.                 else
  759.                 {
  760.                     if(MType==1)
  761.                     {
  762.                         firstI=actI;
  763.                         amenu->FirstItem=firstI;
  764.                     }
  765.                     else
  766.                     {
  767.                         Sfirst=actI;
  768.                         aitem->Sub=Sfirst;
  769.                     }
  770.                 }
  771.                 actI->Next=helpJ;
  772.                 helpJ->Parent=actI;
  773.                 actI->TopEdge=helpJ->TopEdge;
  774.                 while(helpJ)
  775.                 {
  776.                     helpJ->TopEdge+=actI->Height;
  777.                     helpJ=helpJ->Next;
  778.                 }
  779.             }
  780.             POK=0;
  781.         }
  782.         break;
  783.         case MOUSEMOVE: SY=1;
  784.                 break;
  785.         case GADGETDOWN: TestProp();
  786.                 break;
  787.         }
  788.         Modify();
  789.     }
  790.     }while(POK==1);
  791.     if(MType==1)
  792.     {
  793.         Ianz++;
  794.         if((Inr+9)<Ianz) Inr++;
  795.         aitem=actI;
  796.         SetIDefines();
  797.     }
  798.     else
  799.     {
  800.         Sanz++;
  801.         if((Snr+9)<Sanz) Snr++;
  802.         asub=actI;
  803.         SetIDefines();
  804.     }
  805.     NewExclude();
  806.     MenuOn(1);
  807.     SetDrMd(Mrp,JAM1|COMPLEMENT);
  808.     RectFill(Mrp,122,138,209,146);
  809. }
  810. VOID AktM()
  811. {
  812.     helpM=awin->MenuStrip;
  813.     if(helpM)
  814.     {
  815.         for(i=0; i<Mnr; i++)
  816.             helpM=helpM->Next;
  817.     }
  818.     i=1;
  819.     amenu=helpM;
  820.     while(i != Id && amenu != NULL)
  821.     {
  822.         helpM=helpM->Next;
  823.         amenu=helpM;
  824.         i++;
  825.     }
  826. }
  827. VOID AktI()
  828. {
  829.     helpJ=aitem->Sub;
  830.     j=Snr;
  831.     if(MType==1)
  832.     {
  833.         helpJ=amenu->FirstItem;
  834.         j=Inr;
  835.     }
  836.     if(helpJ)
  837.     {
  838.         for(i=0; i<j; i++)
  839.             helpJ=helpJ->Next;
  840.         i=1;
  841.         while(i != Id && helpJ != NULL)
  842.         {
  843.             helpJ=helpJ->Next;
  844.             i++;
  845.         }
  846.     }
  847. }
  848. VOID NewLeftI()
  849. {
  850.     while(helpT)
  851.     {
  852.         helpT->LeftEdge=0;
  853.         if(actI->Flags & CHECKIT)
  854.         {
  855.             helpT->LeftEdge=19;
  856.             if(awin->CheckMark)
  857.                 helpT->LeftEdge=awin->CheckMark->Width+4;
  858.         }
  859.         helpT=helpT->NextText;
  860.     }
  861. }
  862. VOID NewLeftM()
  863. {
  864.     helpM=amenu->Next;
  865.     helpM->LeftEdge=amenu->LeftEdge;
  866.     helpM=helpM->Next;
  867.     while(helpM)
  868.     {
  869.         helpM->LeftEdge=helpM->Parent->LeftEdge+helpM->Parent->Width;
  870.         helpM=helpM->Next;
  871.     }
  872. }
  873. VOID NewTop()
  874. {
  875.     helpJ=asub->Next;
  876.     helpJ->TopEdge=asub->TopEdge;
  877.     if(MType==1)
  878.     {
  879.         helpJ=aitem->Next;
  880.         helpJ->TopEdge=aitem->TopEdge;
  881.     }
  882.     helpJ=helpJ->Next;
  883.     while(helpJ)
  884.     {
  885.         helpJ->TopEdge=helpJ->Parent->TopEdge+helpJ->Parent->Height;
  886.         helpJ=helpJ->Next;
  887.     }
  888. }
  889. VOID NewTopI()
  890. {
  891.     helpJ=asub->Next;
  892.     if(MType==1) helpJ=aitem->Next;
  893.     while(helpJ)
  894.     {
  895.         if(helpJ->Auto)
  896.             helpJ->TopEdge=helpJ->Parent->TopEdge+helpJ->Parent->Height;
  897.         helpJ=helpJ->Next;
  898.     }
  899. }
  900. VOID DelMenuAll()
  901. {
  902.     amenu=awin->MenuStrip;
  903.     while(amenu)
  904.     {
  905.         helpM=amenu->Next;
  906.         DelMenu();
  907.         amenu=helpM;
  908.     }
  909.     NoMenu();
  910. }
  911. VOID NoMenu()
  912. {
  913.     firstM=NULL;
  914.     lastM=NULL;
  915.     awin->MenuStrip=NULL;
  916.     
  917. }
  918. VOID NoItem()
  919. {
  920.     firstI=NULL;
  921.     lastI=NULL;
  922.     amenu->FirstItem=NULL;
  923. }
  924. VOID NoSub()
  925. {
  926.     Sfirst=NULL;
  927.     Slast=NULL;
  928.     aitem->Sub=NULL;
  929. }
  930. VOID DelMenu()
  931. {
  932.     aitem=amenu->FirstItem;
  933.     while(aitem)
  934.     {
  935.         actI=aitem->Next;
  936.         DelItem();
  937.         aitem=actI;
  938.     }
  939.     FreeMem(amenu,sizeof(struct MyMenu));
  940. }
  941. VOID DelItem()
  942. {
  943.     asub=aitem->Sub;
  944.     while(asub)
  945.     {
  946.         actS=asub->Next;
  947.         DelSub();
  948.         asub=actS;
  949.     }
  950.     if(aitem->ItemText) DelText(aitem->ItemText);
  951.     if(aitem->SelectText) DelText(aitem->SelectText);
  952.     helpI=aitem->ItemImage;
  953.     DelImage(2);
  954.     helpI=aitem->SelectImage;
  955.     DelImage(3);
  956.     FreeMem(aitem,sizeof(struct MyItem));
  957. }
  958. VOID DelSub()
  959. {
  960.     if(asub->ItemText) DelText(asub->ItemText);
  961.     if(asub->SelectText) DelText(asub->SelectText);
  962.     helpI=asub->ItemImage;
  963.     DelImage(4);
  964.     helpI=asub->SelectImage;
  965.     DelImage(5);
  966.     FreeMem(asub,sizeof(struct MyItem));
  967. }
  968. VOID MAus()
  969. {
  970.     if(Mwin->MenuStrip) ClearMenuStrip(Mwin);
  971. }
  972. VOID MEin()
  973. {
  974.     if(awin->MenuStrip) SetMenuStrip(Mwin,&awin->MenuStrip->Menu);
  975. }
  976. VOID RetteMenu()
  977. {
  978.     if(Mauto)
  979.     {
  980.         Mleft=0;
  981.         Mtop=0;
  982.         Mheight=8;
  983.         if(TxS==10) Mheight=9;
  984.         Mwidth=(strlen(TITLEBuff)*TxS)+7;
  985.         if(amenu->Parent)
  986.         {
  987.             Mleft=(amenu->Parent->LeftEdge+amenu->Parent->Width)+7;
  988.             Mtop=amenu->Parent->TopEdge;
  989.             Mheight=amenu->Parent->Height;
  990.         }
  991.         InBuffer();
  992.         RefreshGList(&MLeft,Mwin,NULL,4);
  993.     }
  994.     amenu->Width=Mwidth;
  995.     amenu->Height=Mheight;
  996.     amenu->LeftEdge=Mleft;
  997.     amenu->TopEdge=Mtop;
  998.     amenu->Flags=Mflag;
  999.     amenu->Auto=Mauto;
  1000.     strcpy(amenu->MName,TITLEBuff);
  1001.     MenuOn(1);
  1002.     ShowMenu();
  1003.     SaveOk=1;
  1004. }
  1005. VOID InBuffer()
  1006. {
  1007.     sprintf(LEFTBuff,"%d",Mleft);
  1008.     sprintf(TOPBuff,"%d",Mtop);
  1009.     sprintf(HEIGHTBuff,"%d",Mheight);
  1010.     sprintf(WIDTHBuff,"%d",Mwidth);
  1011. }
  1012. VOID RetteItem(UBYTE m)
  1013. {
  1014.     struct MyItem *item;
  1015.     actI=asub;
  1016.     if(MType==1) actI=aitem;
  1017.     actI->Flags=Mflag;
  1018.     actI->Auto=Mauto;
  1019.     actI->IstWidth=Mwidth;
  1020.     strcpy(actI->ItemName,TITLEBuff);
  1021.     actI->Width=Mwidth;
  1022.     actI->Height=Mheight;
  1023.     actI->LeftEdge=Mleft;
  1024.     actI->TopEdge=Mtop;
  1025.     actI->Command=0;
  1026.     if(strlen(Icom)) actI->Command=Icom[0];
  1027.     if(Mauto)
  1028.     {
  1029.         item=actI;
  1030.         ItemAuto();
  1031.         actI=item;
  1032.         Mwidth=actI->Width;
  1033.         Mheight=actI->Height;
  1034.         Mleft=actI->LeftEdge;
  1035.         Mtop=actI->TopEdge;
  1036.         InBuffer();
  1037.         RefreshGList(&ILeft,Mwin,NULL,4);
  1038.     }
  1039.     NewWidth();
  1040.     NewTopI();
  1041.     if(m)
  1042.     {
  1043.         ShowItem();
  1044.         MenuOn(1);
  1045.     }
  1046.     SaveOk=1;
  1047. }
  1048. VOID ItemAuto()
  1049. {
  1050.     actI=aitem;
  1051.     actI->LeftEdge=0;
  1052.     if(MType==2)
  1053.     {
  1054.         actI=asub;
  1055.         actI->LeftEdge=aitem->Width;
  1056.     }
  1057.     actI->TopEdge=0;
  1058.     actI->Height=8;
  1059.     if(TxS==10) actI->Height=9;
  1060.     if(actI->Parent)
  1061.     {
  1062.         actI->TopEdge=actI->Parent->TopEdge+actI->Parent->Height;
  1063.         actI->LeftEdge=actI->Parent->LeftEdge;
  1064.     }
  1065.     if(actI->ItemImage==NULL)
  1066.     {
  1067.         if(actI->ItemText)
  1068.             actI->Width=strlen(actI->ItemText->IText)*TxS;
  1069.         else actI->Width=strlen(TITLEBuff)*TxS;
  1070.     }
  1071.     else
  1072.     {
  1073.         i=0;
  1074.         j=0;
  1075.         x=0;
  1076.         y=0;
  1077.         actI->ItemImage->LeftEdge=0;
  1078.         actI->ItemImage->TopEdge=0;
  1079.         i=actI->ItemImage->Height;
  1080.         x=actI->ItemImage->Width;
  1081.         if(actI->Flags & CHECKIT)
  1082.         {
  1083.             d=19;
  1084.             if(awin->CheckMark)
  1085.                 d=awin->CheckMark->Width+4;
  1086.             actI->ItemImage->LeftEdge = d;
  1087.         }
  1088.         if(actI->SelectImage && actI->ItemImage)
  1089.         {
  1090.             actI->SelectImage->LeftEdge=0;
  1091.             actI->SelectImage->TopEdge=0;
  1092.             j=actI->SelectImage->Height;
  1093.             y=actI->SelectImage->Width;
  1094.             if(actI->Flags & CHECKIT)
  1095.             {
  1096.                 d=19;
  1097.                 if(awin->CheckMark)
  1098.                     d=awin->CheckMark->Width+4;
  1099.                 actI->SelectImage->LeftEdge = d;
  1100.             }
  1101.         }
  1102.         if(i < j) actI->Height=j;
  1103.         else actI->Height=i;
  1104.         if(x < y) actI->Width=y;
  1105.         else actI->Width=x;
  1106.     }
  1107.     if(actI->Flags & CHECKIT)
  1108.     {
  1109.         d=19;
  1110.         if(awin->CheckMark)
  1111.         {
  1112.             helpI=awin->CheckMark;
  1113.             d=helpI->Width+4;
  1114.             if(actI->Height < helpI->Height)
  1115.                 actI->Height=helpI->Height;
  1116.         }
  1117.         actI->Width+=d;
  1118.     }
  1119.     if(actI->Command)
  1120.     {
  1121.         if(TxS==8) actI->Width+=37;
  1122.         else actI->Width+=40;
  1123.     }
  1124.     actI->IstWidth=actI->Width;
  1125.     helpT=actI->ItemText;
  1126.     NewLeftI();
  1127.     helpT=actI->SelectText;
  1128.     NewLeftI();
  1129.     NewWidth();
  1130.     NewTopI();
  1131. }
  1132. VOID MenuOn(UBYTE m)
  1133. {
  1134.     if(m) MAus();
  1135.     MakeMenu();
  1136.     MEin();
  1137. }
  1138. VOID SetMDefines()
  1139. {
  1140.     MEingabeInfo.DispPos=0;
  1141.     TITLEBuff[0]=0;
  1142.     Mwidth=0;
  1143.     Mheight=0;
  1144.     Mflag=MENUENABLED;
  1145.     Mleft=0;
  1146.     Mtop=0;
  1147.     Mauto=1;
  1148.     if(amenu) 
  1149.     {
  1150.         strcpy(TITLEBuff,amenu->MName);
  1151.         Mtop=amenu->TopEdge;
  1152.         Mleft=amenu->LeftEdge;
  1153.         Mwidth=amenu->Width;
  1154.         Mheight=amenu->Height;
  1155.         Mflag=amenu->Flags;
  1156.         Mauto=amenu->Auto;
  1157.     }
  1158.     InBuffer();
  1159.     MFlag.Flags=NULL;
  1160.     if(Mflag) MFlag.Flags=SELECTED;
  1161.     MAuto.Flags=GRELRIGHT;
  1162.     if(Mauto) MAuto.Flags=GRELRIGHT|SELECTED;
  1163.     SetPen(Mrp,0,JAM1);
  1164.     RectFill(Mrp,50,171,137,179);
  1165.     RectFill(Mrp,190,89,249,108);
  1166.     RefreshGList(&MEingabe,Mwin,NULL,8);
  1167.     SetMWert();
  1168.     if(OldMenu != amenu)
  1169.     {
  1170.         HolItem();
  1171.         OldMenu=amenu;
  1172.     }
  1173. }
  1174. VOID SetIDefines()
  1175. {
  1176.     actI=aitem;
  1177.     if(MType==2) actI=asub;
  1178.     MEingabeInfo.DispPos=0;
  1179.     TITLEBuff[0]=0;
  1180.     Mtop=0;
  1181.     Mleft=0;
  1182.     Mwidth=0;
  1183.     Mheight=0;
  1184.     Mflag=ITEMENABLED|HIGHCOMP;
  1185.     Mauto=1;
  1186.     if(actI)
  1187.     {
  1188.         strcpy(TITLEBuff,actI->ItemName);
  1189.         Mtop=actI->TopEdge;
  1190.         Mleft=actI->LeftEdge;
  1191.         Mwidth=actI->Width;
  1192.         Mheight=actI->Height;
  1193.         Mflag=actI->Flags;
  1194.         Mauto=actI->Auto;
  1195.         Icom[0]=0;
  1196.         if(actI->Command)
  1197.         {
  1198.             Icom[0]=actI->Command;
  1199.             Icom[1]='\0';
  1200.         }
  1201.     }
  1202.     InBuffer();
  1203.     strcpy(DEPTHBuff,Icom);
  1204.     MAuto.Flags=GRELRIGHT;
  1205.     if(Mauto) MAuto.Flags=GRELRIGHT|SELECTED;
  1206.     SetPen(Mrp,0,JAM1);
  1207.     RectFill(Mrp,6,128,93,196);
  1208.     RectFill(Mrp,122,122,209,130);
  1209.     RectFill(Mrp,240,89,299,108);
  1210.     RefreshGList(&MAuto,Mwin,NULL,1);
  1211.     for(i=0; i<4; i++)
  1212.     {
  1213.         IFlag[i].Flags=NULL;
  1214.         if(Mflag & MFLAGS[i]) IFlag[i].Flags=SELECTED;
  1215.     }
  1216.     if(MType==1) SetIWert();
  1217.     else SetSWert();
  1218.     RefreshGList(&IEingabe,Mwin,NULL,13);
  1219.     SetDrMd(Mrp,JAM1|COMPLEMENT);
  1220.     for(i=4; i<7; i++)
  1221.     {
  1222.         y=128+((i-4)*12);
  1223.         if((Mflag & MFLAGS[i]) == MFLAGS[i])
  1224.             RectFill(Mrp,6,y,93,y+8);
  1225.     }
  1226.     if(MType==1)
  1227.     {
  1228.         if(OldItem != aitem)
  1229.         {
  1230.             HolSub();
  1231.             OldItem=aitem;
  1232.         }
  1233.     }
  1234. }
  1235. VOID HolItem()
  1236. {
  1237.     aitem=NULL;
  1238.     if(amenu) aitem=amenu->FirstItem;
  1239.     firstI=aitem;
  1240.     lastI=aitem;
  1241.     Inr=0;
  1242.     Ianz=0;
  1243.     while(aitem)
  1244.     {
  1245.         lastI=aitem;
  1246.         Ianz++;
  1247.         aitem=aitem->Next;
  1248.         if(Ianz > 9) Inr++;
  1249.     }
  1250.     aitem=lastI;
  1251.     if(aitem==NULL) NoItem();
  1252.     else HolSub();
  1253. }
  1254. VOID HolSub()
  1255. {
  1256.     asub=NULL;
  1257.     if(aitem) asub=aitem->Sub;
  1258.     Sfirst=asub;
  1259.     Slast=asub;
  1260.     Snr=0;
  1261.     Sanz=0;
  1262.     while(asub)
  1263.     {
  1264.         Slast=asub;
  1265.         Sanz++;
  1266.         asub=asub->Next;
  1267.         if(Sanz > 9) Snr++;
  1268.     }
  1269.     asub=Slast;
  1270.     if(asub==NULL) NoSub();
  1271. }
  1272. VOID ShowMenu()
  1273. {
  1274.     SetPen(Mrp,1,JAM2);
  1275.     SetBPen(Mrp,2);
  1276.     helpM=awin->MenuStrip;
  1277.     for(i=0; i<Mnr; i++)
  1278.         helpM=helpM->Next;
  1279.     for(i=0; i<10; i++)
  1280.     {
  1281.         LEER[0]=0;
  1282.         Move(Mrp,34,26+(i*8));
  1283.         if(helpM)
  1284.         {
  1285.             strncpy(LEER,helpM->MName,15);
  1286.             helpM=helpM->Next;
  1287.         }
  1288.         for(j=strlen(LEER); j<15; j++)
  1289.             strcat(LEER," ");
  1290.         Text(Mrp,LEER,15);
  1291.     }
  1292. }
  1293. VOID NewBit()
  1294. {
  1295.     actI=amenu->FirstItem;
  1296.     if(MType==2) actI=aitem->Sub;
  1297.     read=1;
  1298.     while(actI)
  1299.     {
  1300.         actI->Bit=read;
  1301.         read = read << 1;
  1302.         actI=actI->Next;
  1303.     }
  1304. }
  1305. VOID ShowItem()
  1306. {
  1307.     SetPen(Mrp,1,JAM2);
  1308.     SetBPen(Mrp,2);
  1309.     actI=aitem;
  1310.     helpJ=amenu->FirstItem;
  1311.     nr=Inr;
  1312.     if(MType==2)
  1313.     {
  1314.         actI=asub;
  1315.         helpJ=aitem->Sub;
  1316.         nr=Snr;
  1317.     }
  1318.     for(i=0; i<nr; i++)
  1319.         helpJ=helpJ->Next;
  1320.     for(i=0; i<10; i++)
  1321.     {
  1322.         LEER[0]=0;
  1323.         y=26+(i*8);
  1324.         SetAPen(Mrp,1);
  1325.         Move(Mrp,34,y);
  1326.         if(helpJ) strncpy(LEER,helpJ->ItemName,15);
  1327.         for(j=strlen(LEER); j<15; j++)
  1328.             strcat(LEER," ");
  1329.         Text(Mrp,LEER,15);
  1330.         Move(Mrp,155,y);
  1331.         SetAPen(Mrp,3);
  1332.         if(helpJ)
  1333.         {
  1334.             if(actI->Exclude & helpJ->Bit) Text(Mrp,"E",1);
  1335.             else Text(Mrp,"-",1);
  1336.             helpJ=helpJ->Next;
  1337.         }
  1338.         else Text(Mrp," ",1);
  1339.     }
  1340. }
  1341. VOID SetPen(struct RastPort *r,UBYTE c,UBYTE m)
  1342. {
  1343.     SetAPen(r,c);
  1344.     SetDrMd(r,m);
  1345. }
  1346. VOID SetMWert()
  1347. {
  1348.     ShowMenu();
  1349.     SetWert(Mnr,Manz,Mwin,&MenuProp,&MenuPropInfo);
  1350. }
  1351. VOID SetIWert()
  1352. {
  1353.     ShowItem();
  1354.     SetWert(Inr,Ianz,Mwin,&MenuProp,&MenuPropInfo);
  1355. }
  1356. VOID SetSWert()
  1357. {
  1358.     ShowItem();
  1359.     SetWert(Snr,Sanz,Mwin,&MenuProp,&MenuPropInfo);
  1360. }
  1361. VOID SetWert(USHORT no,USHORT fmax,struct Window *win,
  1362.         struct Gadget *gadget,struct PropInfo *info)
  1363. {
  1364.     USHORT VB=0;
  1365.     if(no) VB=65535*no/(fmax-9);
  1366.     size=65535;
  1367.     if(fmax>9) size=65535*9/fmax;
  1368.     info->VertPot=VB;
  1369.     info->VertBody=size;
  1370.     RefreshGList(gadget,win,NULL,1);
  1371. }
  1372. VOID MakeMenu()
  1373. {
  1374.     helpM=awin->MenuStrip;
  1375.     while(helpM)
  1376.     {
  1377.         helpM->Menu.NextMenu=NULL;
  1378.         if(helpM->Parent)
  1379.             helpM->Parent->Menu.NextMenu=&helpM->Menu;
  1380.         helpM->Menu.LeftEdge=helpM->LeftEdge;
  1381.         helpM->Menu.TopEdge=helpM->TopEdge;
  1382.         helpM->Menu.Width=helpM->Width;
  1383.         helpM->Menu.Height=helpM->Height;
  1384.         helpM->Menu.Flags=helpM->Flags;
  1385.         helpM->Menu.MenuName=helpM->MName;
  1386.         helpM->Menu.FirstItem=NULL;
  1387.         if(helpM->FirstItem) MakeMenuItem();
  1388.         helpM=helpM->Next;
  1389.     }
  1390. }
  1391. VOID MakeItem()
  1392. {
  1393.     actI->Item.NextItem=NULL;
  1394.     if(actI->Parent)
  1395.         actI->Parent->Item.NextItem=&actI->Item;
  1396.     actI->Item.LeftEdge=actI->LeftEdge;
  1397.     actI->Item.TopEdge=actI->TopEdge;
  1398.     actI->Item.Flags=actI->Flags;
  1399.     actI->Item.Width=actI->Width;
  1400.     actI->Item.Height=actI->Height;
  1401.     actI->Item.MutualExclude=actI->Exclude;
  1402.     actI->Item.ItemFill=NULL;
  1403.     actI->Item.SelectFill=NULL;
  1404.     if(actI->ItemText != NULL && actI->ItemImage==NULL)
  1405.     {
  1406.         helpT=actI->ItemText;
  1407.         MakeText();
  1408.         actI->Item.ItemFill=(APTR)&actI->ItemText->Text;
  1409.         actI->Item.Flags |= ITEMTEXT;
  1410.         if(actI->SelectText != NULL)
  1411.         {
  1412.             helpT=actI->SelectText;
  1413.             MakeText();
  1414.             actI->Item.SelectFill=(APTR)&actI->SelectText->Text;
  1415.             actI->Item.Flags &= 0xFF3F;
  1416.         }
  1417.     }
  1418.     if(actI->ItemImage)
  1419.     {
  1420.         helpI=actI->ItemImage;
  1421.         MakeImage();
  1422.         actI->Item.ItemFill=(APTR)&actI->ItemImage->Image;
  1423.         actI->Item.Flags &= 0xFFFD;
  1424.         if((actI->Flags & HIGHFLAGS)==0)
  1425.             actI->Item.Flags |= HIGHCOMP;
  1426.         if(actI->SelectImage)
  1427.         {
  1428.             helpI=actI->SelectImage;
  1429.             MakeImage();
  1430.             actI->Item.SelectFill=(APTR)&actI->SelectImage->Image;
  1431.             actI->Item.Flags &= 0xFF3D;
  1432.         }
  1433.     }
  1434.     actI->Item.Command=actI->Command;
  1435.     if(actI->Command) actI->Item.Flags |= COMMSEQ;
  1436.     actI->Item.SubItem=NULL;
  1437.     actI->Item.NextSelect=MENUNULL;
  1438. }
  1439. VOID MakeMenuItem()
  1440. {
  1441.     helpJ=helpM->FirstItem;
  1442.     while(helpJ)
  1443.     {
  1444.         actI=helpJ;
  1445.         MakeItem();
  1446.         if(helpJ->Sub) MakeSub();
  1447.         helpJ=helpJ->Next; 
  1448.     }
  1449.     helpM->Menu.FirstItem=&helpM->FirstItem->Item;
  1450. }
  1451. VOID MakeSub()
  1452. {
  1453.     Shelp=helpJ->Sub;
  1454.     while(Shelp)
  1455.     {
  1456.         actI=Shelp;
  1457.         MakeItem();
  1458.         Shelp=Shelp->Next;
  1459.     }
  1460.     helpJ->Item.SubItem=&helpJ->Sub->Item;
  1461. }
  1462. USHORT NoText()
  1463. {
  1464.     firstT=NULL;
  1465.     lastT=NULL;
  1466.     left=0;
  1467.     top=0;
  1468.     dm=COMPLEMENT;
  1469.     front=3;
  1470.     back=1;
  1471.     style=0;
  1472.     f1=1;
  1473.     if(TxS==10) f1=2;
  1474.     if(NewText()) return(1);
  1475.     return(0);
  1476. }
  1477. USHORT NewMenu()
  1478. {
  1479.     if(Manz==31)
  1480.     {
  1481.         Error(23,1,1);
  1482.         amenu=lastM;
  1483.         return(1);
  1484.     }
  1485.     if(amenu=(struct MyMenu *)
  1486.         AllocMem(sizeof(struct MyMenu),MEMF_CLEAR|MEMF_PUBLIC))
  1487.     {
  1488.         Manz++;
  1489.         if((Mnr+9)<Manz) Mnr++;
  1490.         if(firstM==NULL)
  1491.         {
  1492.             firstM=amenu;
  1493.             awin->MenuStrip=firstM;
  1494.         }
  1495.         else
  1496.         {
  1497.             lastM->Next=amenu;
  1498.             amenu->LeftEdge=7+(lastM->LeftEdge+lastM->Width);
  1499.             amenu->Height=lastM->Height;
  1500.             amenu->TopEdge=lastM->TopEdge;
  1501.         }
  1502.         amenu->Parent=lastM;
  1503.         amenu->Flags=MENUENABLED;
  1504.         amenu->Auto=1;
  1505.         sprintf(LEER,"%d",Manz);
  1506.         strcpy(amenu->MName,"Menu_");
  1507.         strcat(amenu->MName,LEER);
  1508.         amenu->Width=(strlen(amenu->MName)*TxS)+7;
  1509.         lastM=amenu;
  1510.         WMItem5.Flags=ItemOn;
  1511.         WMItem5b.Flags=ItemOn;
  1512.         MenuOn(1);
  1513.         HolItem();
  1514.         OldMenu=amenu;
  1515.         OldItem=aitem;
  1516.         return(0);
  1517.     }
  1518.     Error(0,1,1);
  1519.     amenu=lastM;
  1520.     return(1);
  1521. }
  1522. USHORT NewItem()
  1523. {
  1524.     if(Ianz==63)
  1525.     {
  1526.         Error(24,1,1);
  1527.         aitem=lastI;
  1528.         return(1);
  1529.     }
  1530.     if(aitem=(struct MyItem *)
  1531.         AllocMem(sizeof(struct MyItem),MEMF_CLEAR|MEMF_PUBLIC))
  1532.     {
  1533.         if(NoText())
  1534.         {
  1535.             FreeMem(aitem,sizeof(struct MyItem));
  1536.             aitem=lastI;
  1537.             Error(0,1,1);
  1538.             return(1);
  1539.         }
  1540.         Ianz++;
  1541.         if((Inr+9)<Ianz) Inr++;
  1542.         strcpy(aitem->ItemName,"Item_");
  1543.         sprintf(LEER,"%d",Ianz);
  1544.         strcat(aitem->ItemName,LEER);
  1545.         strcpy(TITLEBuff,aitem->ItemName);
  1546.         aitem->IstWidth=strlen(aitem->ItemName)*TxS;;
  1547.         aitem->Width=aitem->IstWidth;
  1548.         aitem->Height=8;
  1549.         if(TxS==10) aitem->Height=9;
  1550.         if(firstI==NULL)
  1551.         {
  1552.             firstI=aitem;
  1553.             amenu->FirstItem=firstI;
  1554.             aitem->Flags=HIGHCOMP|ITEMENABLED;
  1555.         }
  1556.         else
  1557.         {
  1558.             lastI->Next=aitem;
  1559.             aitem->LeftEdge=lastI->LeftEdge;
  1560.             aitem->TopEdge=(lastI->TopEdge+lastI->Height);
  1561.             aitem->Flags=lastI->Flags;
  1562.             if(lastI->Width > aitem->Width)
  1563.                 aitem->Width=lastI->Width;
  1564.         }
  1565.         aitem->Parent=lastI;
  1566.         aitem->Auto=1;
  1567.         aitem->ItemText=firstT;
  1568.         strcpy(firstT->IText,aitem->ItemName);
  1569.         aitem->NextSelect=MENUNULL;
  1570.         lastI=aitem;
  1571.         MenuOn(1);
  1572.         NewBit();
  1573.         HolSub();
  1574.         OldItem=aitem;
  1575.         return(0);
  1576.     }
  1577.     Error(0,1,1);
  1578.     aitem=lastI;
  1579.     return(1);
  1580. }
  1581. USHORT NewSub()
  1582. {
  1583.     if(Sanz==31)
  1584.     {
  1585.         Error(25,1,1);
  1586.         asub=Slast;
  1587.         return(1);
  1588.     }
  1589.     if(asub=(struct MyItem *)
  1590.         AllocMem(sizeof(struct MyItem),MEMF_CLEAR|MEMF_PUBLIC))
  1591.     {
  1592.         if(NoText())
  1593.         {
  1594.             FreeMem(asub,sizeof(struct MyItem));
  1595.             asub=Slast;
  1596.             Error(0,1,1);
  1597.             return(1);
  1598.         }
  1599.         Sanz++;
  1600.         if((Snr+9)<Sanz) Snr++;
  1601.         strcpy(asub->ItemName,"SubItem_");
  1602.         sprintf(LEER,"%d",Sanz);
  1603.         strcat(asub->ItemName,LEER);
  1604.         strcpy(TITLEBuff,asub->ItemName);
  1605.         asub->IstWidth=strlen(asub->ItemName)*TxS;
  1606.         asub->Width=asub->IstWidth;
  1607.         asub->Height=8;
  1608.         if(TxS==10) asub->Height=9;
  1609.         if(Sfirst==NULL)
  1610.         {
  1611.             Sfirst=asub;
  1612.             aitem->Sub=Sfirst;
  1613.             asub->LeftEdge=aitem->Width;
  1614.             asub->Flags=HIGHCOMP|ITEMENABLED;
  1615.         }
  1616.         else
  1617.         {
  1618.             Slast->Next=asub;
  1619.             asub->LeftEdge=Slast->LeftEdge;
  1620.             asub->TopEdge=(Slast->TopEdge+Slast->Height);
  1621.             asub->Flags=Slast->Flags;
  1622.             if(Slast->Width > asub->Width)
  1623.                 asub->Width=Slast->Width;
  1624.         }
  1625.         asub->Parent=Slast;
  1626.         asub->Auto=1;
  1627.         asub->ItemText=firstT;
  1628.         strcpy(firstT->IText,asub->ItemName);
  1629.         asub->NextSelect=MENUNULL;
  1630.         Slast=asub;
  1631.         MenuOn(1);
  1632.         NewBit();
  1633.         return(0);
  1634.     }
  1635.     Error(0,1,1);
  1636.     asub=Slast;
  1637.     return(1);
  1638. }
  1639.  
  1640.